.PHONY: all clean push-staging build-staging

COS_RELEASE_BUCKET = www-store-lazycat-1301583638/_modules/assistant/


UI_DIR = ../
UI_INDEX := $(UI_DIR)/dist/index.html
UI_PACKAGE := $(UI_DIR)/dist/node_modules/.package-lock.json

UI_SOURCE := \
	$(shell find $(UI_DIR) -not -path '$(UI_DIR)/node_modules/*' -and -not -path '$(UI_DIR)/dist/*' -and -type f) \
	$(NULL)

# all
all: $(UI_INDEX)

push-release:
	cd $(UI_DIR); coscli sync -r dist/ cos://$(COS_RELEASE_BUCKET) -e cos.ap-guangzhou.myqcloud.com; \
	curl -X POST --header 'Content-Type: application/json' --header "Authorization: Bearer $${TESTFLIGHT_API_TOKEN}" 'https://testflight.lazycat.cloud/api/cdn/refresh' --data-raw '{"Dirs": [{"Url": "https://appstore.lazycat.cloud/_modules/assistant"}]}';\


$(UI_DIR)/node_modules/.package-lock.json: $(UI_DIR)/package-lock.json
	cd $(UI_DIR); npm clean-install --registry https://registry.npmmirror.com

# ui
$(UI_INDEX): $(UI_SOURCE) $(UI_DIR)/node_modules/.package-lock.json
	cd $(UI_DIR); npm run build
clean:
	rm -rf $(UI_DIR)/dist
